<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>SSM  &middot; sitename</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">


<meta name="description" content="SSM description" />

<meta name="keywords" content="one, two, ">


<meta property="og:title" content="SSM  &middot; sitename ">
<meta property="og:site_name" content="sitename"/>
<meta property="og:url" content="https://lvzongcheng.gitee.io/framework/ssm/" />
<meta property="og:locale" content="en-EN">


<meta property="og:type" content="article" />
<meta property="og:description" content="SSM description"/>
<meta property="og:article:published_time" content="2017-12-14T00:00:00Z" />
<meta property="og:article:modified_time" content="2017-12-14T00:00:00Z" />

  
    
<meta property="og:article:tag" content="one">
    
<meta property="og:article:tag" content="two">
    
  

  

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Article",
    "headline": "SSM",
    "author": {
      "@type": "Person",
      "name": "LvZongCheng"
    },
    "datePublished": "2017-12-14",
    "description": "SSM description",
    "wordCount":  862 
  }
</script>



<link rel="canonical" href="https://lvzongcheng.gitee.io/framework/ssm/" />

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://lvzongcheng.gitee.io/touch-icon-144-precomposed.png">
<link href="https://lvzongcheng.gitee.io/favicon.png" rel="icon">

<meta name="generator" content="Hugo 0.60.0" />

  <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<link href='https://fonts.googleapis.com/css?family=Merriweather:300%7CRaleway%7COpen+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/highlight/default.css">

  
  
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'Your Google Analytics tracking code', 'auto');
	  ga('send', 'pageview');

	</script>

</head>
<body>
  <main id="main-wrapper" class="container main_wrapper has-sidebar">
    <header id="main-header" class="container main_header">
  <div class="container brand">
  <div class="container title h1-like">
  <a class="baselink" href="https://lvzongcheng.gitee.io">
  LvZongCheng

</a>

</div>

  
<div class="container topline">
  
  淡定 执著 进取 自律


</div>


</div>

  <nav class="container nav primary no-print">
  

<a class="homelink" href="https://lvzongcheng.gitee.io">home</a>


  
<a href="https://lvzongcheng.gitee.io/framework" title="Show list of Frameworks">Frameworks</a>

<a href="https://lvzongcheng.gitee.io/java" title="Show list of Java">Java</a>

<a href="https://lvzongcheng.gitee.io/linux" title="Show list of Linux">Linux</a>

<a href="https://lvzongcheng.gitee.io/redis" title="Show list of Redis">Redis</a>

<a href="https://lvzongcheng.gitee.io/sql" title="Show list of SQL">SQL</a>

<a href="https://lvzongcheng.gitee.io/Spring" title="Show list of Spring">Spring</a>

<a href="https://lvzongcheng.gitee.io/tools" title="Show list of Tools">Tools</a>

<a href="https://lvzongcheng.gitee.io/webpage" title="Show list of WebPage">WebPage</a>

<a href="https://lvzongcheng.gitee.io/information" title="Show list of information">information</a>

<a href="https://lvzongcheng.gitee.io/network" title="Show list of network">network</a>

<a href="https://lvzongcheng.gitee.io/%E5%BE%AE%E6%9C%8D%E5%8A%A1" title="Show list of 微服务">微服务</a>

<a href="https://lvzongcheng.gitee.io/%E6%80%BB%E7%BB%93" title="Show list of 总结">总结</a>

<a href="https://lvzongcheng.gitee.io/%E6%9C%BA%E5%99%A8%E8%87%AA%E5%8A%A8%E5%8C%96" title="Show list of 机器自动化">机器自动化</a>

<a href="https://lvzongcheng.gitee.io/%E6%B1%87%E7%BC%96" title="Show list of 汇编">汇编</a>

<a href="https://lvzongcheng.gitee.io/%E8%AE%B0%E4%BA%8B%E6%9C%AC" title="Show list of 记事本">记事本</a>


</nav>

<div class="container nav secondary no-print">
  
<a id="contact-link-email" class="contact_link" rel="me" aria-label="Email" href="mailto:Lyc19880405@163.com">
  <span class="fa fa-envelope-square"></span></a>



<a id="contact-link-github" class="contact_link" rel="me" aria-label="Github" href="https://github.com/enten/hugo-boilerplate">
  <span class="fa fa-github-square"></span></a>




 


















</div>


  

</header>


<article id="main-content" class="container main_content single">
  <header class="container hat">
  <h1>SSM
</h1>

</header>

  <div class="container content">
  <h6 id="heading">前台:面向的客户(此客户为销售者,而非公司内部容员工)</h6>
<ul>
<li>前端:CSS,DIV,JS,Jquery</li>
<li>后端:SpringMVC,Spring,Mybatis</li>
</ul>
<h6 id="heading1">使用的优化技术</h6>
<ol>
<li>页面静态化(Freemarker)</li>
<li>缓存</li>
</ol>
<ul>
<li>页面缓存(OSCache)</li>
<li>分布式缓存(memcached)</li>
</ul>
<ol start="3">
<li>图片分离(服务器)</li>
<li>负载均衡(解决高并发终级策略)</li>
</ol>
<h6 id="heading2">后台:</h6>
<ul>
<li>前端:CSS,Html,JS,Jquery</li>
<li>后端:SpringMVC/Struts2,Spring,Hibernate/Mybatis</li>
<li>数据库:采用Mysql</li>
<li>图片分离框架:Jersey</li>
</ul>
<h6 id="maven-web">Maven 不能进行web工程发布</h6>
<p>解决办法：
properties&ndash;&gt;Project Facets 选中 Dynamic web Module<br>
Catalog :Internal<br>
Group Id : org.apache.maven.archetypes<br>
Artifact Id:maven-archetype-webapp</p>
<h6 id="pomxml">pom.xml错误：</h6>
<p>Missing artifact com.octo.captcha:
解决办法:</p>
<ol>
<li>Preferences&ndash;&gt;Maven&ndash;&gt;Update Settings  和  Reindex</li>
</ol>
<h6 id="heading3">发布不带项目名</h6>
<p>! <a href="/image/SSM/SSM-03.png">Alt text</a>
去掉勾，ctrl+s 就不会发布，每次启动  tomcat 时才发布</p>
<h6 id="heading4">文件发布和发布位置</h6>
<p>项目右键单击&ndash;&gt;Properties&ndash;&gt;
Deployment Assembly</p>
<p>Deploy Path 发布文件位置
Source  要发布的文件</p>
<hr>
<h6 id="heading5">手动添加第三方类库到自己电脑的本地仓库</h6>
<h3 id="ssm">SSM三大框架整合</h3>
<ol>
<li>创建Maven 项目创建</li>
</ol>
<p><img src="/image/SSM/SSM-01.png" alt="Alt text"></p>
<p><img src="/image/SSM/SSM-02.png" alt="Alt text"></p>
<p><img src="/image/SSM/SSM-03.png" alt="Alt text"></p>
<p>手动创建 WEB-INF 文件夹和web.xml文件</p>
<h4 id="sprngmybatis">整合Sprng、mybatis</h4>
<h6 id="1--webxml">1.  在web.xml</h6>
<ul>
<li>配置Spring监听器 读取上下文</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Spring的监听器 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context-param</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>contextConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>
		<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>classpath:application-context.xml<span style="color:#f92672">&lt;/param-value&gt;</span>
	<span style="color:#f92672">&lt;/context-param&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 监听器 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;listener</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;listener-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.context.ContextLoaderListener	<span style="color:#f92672">&lt;/listener-class&gt;</span>
		<span style="color:#f92672">&lt;/listener&gt;</span>
</code></pre></div><h6 id="2--applicationcontextxmlspring-">2.  配置上下文application-context.xml文件(spring 配置文件)</h6>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 导入全部的配置文件 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;import</span> <span style="color:#a6e22e">resource=</span><span style="color:#e6db74">&#34;config/*.xml&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><h6 id="3--config">3.  配置config文件夹下的所有配置</h6>
<p>config 下xml文件结构，都是Spring扫描了</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#f92672">&lt;beans</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans&#34;</span>
	<span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span> <span style="color:#a6e22e">xmlns:aop=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/aop&#34;</span>
	<span style="color:#a6e22e">xmlns:tx=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/tx&#34;</span> <span style="color:#a6e22e">xmlns:jdbc=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/jdbc&#34;</span>
	<span style="color:#a6e22e">xmlns:context=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/context&#34;</span>
	<span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;
</span><span style="color:#e6db74">     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd&#34;</span><span style="color:#f92672">&gt;</span>
     
		 
<span style="color:#f92672">&lt;/beans&gt;</span>
</code></pre></div><h6 id="4---spring">4.  注解扫描 Spring的配置</h6>
<ul>
<li><code>扫描注意事项</code><br>
<img src="/image/SSM/20170831.png" alt="Alt text"></li>
<li>扫描配置说明</li>
</ul>
<ul>
<li>配置1：</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发  Spring扫描配置  扫描cn.lvc下所有 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.lvc&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><ul>
<li>配置2：<br>
Spring 扫描不包含Controller注解的<br>
context:exclude-filter  不包含 <br>
context:include-filter  包含<br>
type=&quot;annotation&rdquo;  类型为注解<br>
expression=&quot;org.springframework.stereotype.Controller&rdquo; 指 @Controller注解</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发  扫描包   Spring不扫@Controller </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.lvc&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;context:exclude-filter</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;annotation&#34;</span> <span style="color:#a6e22e">expression=</span><span style="color:#e6db74">&#34;org.springframework.stereotype.Controller&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/context:component-scan&gt;</span>
</code></pre></div><p><strong>anotation.xml 配置</strong></p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#f92672">&lt;beans</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans&#34;</span>
	<span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span> <span style="color:#a6e22e">xmlns:aop=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/aop&#34;</span>
	<span style="color:#a6e22e">xmlns:tx=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/tx&#34;</span> <span style="color:#a6e22e">xmlns:jdbc=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/jdbc&#34;</span>
	<span style="color:#a6e22e">xmlns:context=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/context&#34;</span>
	<span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;
</span><span style="color:#e6db74">     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
</span><span style="color:#e6db74">     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd&#34;</span><span style="color:#f92672">&gt;</span>
     
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发  扫描包   Spring不扫@Controller </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.lvc&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;context:exclude-filter</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;annotation&#34;</span> <span style="color:#a6e22e">expression=</span><span style="color:#e6db74">&#34;org.springframework.stereotype.Controller&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/context:component-scan&gt;</span>
	

<span style="color:#f92672">&lt;/beans&gt;</span>
</code></pre></div><p><strong>数据源C3P0 dbcp</strong></p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置C3P0数据源 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;dataSource&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;com.mchange.v2.c3p0.ComboPooledDataSource&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置驱动 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;driverClass&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;${driverClass}&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置请求的Url </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;jdbcUrl&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;${jdbcUrl}&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 用户名 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;user&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;${user}&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 密码 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;password&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;${password}&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
</code></pre></div><p>property.xml 负责读取</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 读取JDBC 配置文件 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;locations&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;list</span><span style="color:#f92672">&gt;</span>
				<span style="color:#f92672">&lt;value</span><span style="color:#f92672">&gt;</span>classpath:jdbc.properties<span style="color:#f92672">&lt;/value&gt;</span>
			<span style="color:#f92672">&lt;/list&gt;</span>
		<span style="color:#f92672">&lt;/property&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
</code></pre></div><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 事务 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;transactionManager&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.jdbc.datasource.DataSourceTransactionManager&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;dataSource&#34;</span> <span style="color:#a6e22e">ref=</span><span style="color:#e6db74">&#34;dataSource&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>

		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 开启注解   @Transation</span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;tx:annotation-driven</span> <span style="color:#a6e22e">transaction-manager=</span><span style="color:#e6db74">&#34;transactionManager&#34;</span><span style="color:#f92672">/&gt;</span>
</code></pre></div><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Mybatis  SqlSessionFactory  会话工厂 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;sqlSessionFactory&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.mybatis.spring.SqlSessionFactoryBean&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 数据源 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;dataSource&#34;</span> <span style="color:#a6e22e">ref=</span><span style="color:#e6db74">&#34;dataSource&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Mybatis的核心 配置文件 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;configLocation&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;classpath:mybatis-config.xml&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>

	 <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 第三种 Mapper动态代理开发  并且 支持扫描  </span><span style="color:#75715e">--&gt;</span>
	 <span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.mybatis.spring.mapper.MapperScannerConfigurer&#34;</span><span style="color:#f92672">&gt;</span>
	 	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 基础包 包下所的接口全扫描    cn.itcast.core.dao,cn.itcast.core.do  </span><span style="color:#75715e">--&gt;</span>
	 	<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;basePackage&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;cn.itcast.core.dao&#34;</span><span style="color:#f92672">/&gt;</span>
	 	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注入工厂 </span><span style="color:#75715e">--&gt;</span>
	 	<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;sqlSessionFactoryBeanName&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;sqlSessionFactory&#34;</span><span style="color:#f92672">/&gt;</span>
	 <span style="color:#f92672">&lt;/bean&gt;</span>
</code></pre></div><h6 id="mybatis-">mybatis 配置文件</h6>
<p>mybatis-config.xml</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; ?&gt;</span>
<span style="color:#75715e">&lt;!DOCTYPE configuration
</span><span style="color:#75715e">PUBLIC &#34;-//mybatis.org//DTD Config 3.0//EN&#34;
</span><span style="color:#75715e">&#34;http://mybatis.org/dtd/mybatis-3-config.dtd&#34;&gt;</span>
<span style="color:#f92672">&lt;configuration</span><span style="color:#f92672">&gt;</span>

<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> setting </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 别名 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;typeAliases</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;package</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;cn.itcast.core.bean&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/typeAliases&gt;</span>
	
<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> Mapper位置  注意: 要求  Dao接口与Mapper配置文件在一个目录下,并且 同名  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;mappers</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;package</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;cn.itcast.core.dao&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/mappers&gt;</span>

<span style="color:#f92672">&lt;/configuration&gt;</span>
</code></pre></div><h4 id="springmvc">与Springmvc整合</h4>
<ol>
<li>在web.xml中配置DispatherServlet   前端控制器
Springmvc.xml的配置
有两个Controller一个处理前台一个处理后台
示例图：
<img src="/image/SSM/20170607-01.png" alt="Alt text"></li>
</ol>
<h5 id="webxml">在web.xml中配置</h5>
<h6 id="heading6">步骤</h6>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	 <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> POS提交乱码解决 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;filter</span><span style="color:#f92672">&gt;</span>
  	<span style="color:#f92672">&lt;filter-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/filter-name&gt;</span>
  	<span style="color:#f92672">&lt;filter-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.filter.CharacterEncodingFilter<span style="color:#f92672">&lt;/filter-class&gt;</span>
  	<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/param-name&gt;</span>
  		<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>UTF-8<span style="color:#f92672">&lt;/param-value&gt;</span>
  	<span style="color:#f92672">&lt;/init-param&gt;</span>
  <span style="color:#f92672">&lt;/filter&gt;</span>
  <span style="color:#75715e">&lt;!--</span><span style="color:#75715e">  *.shtml  *.do </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;filter-mapping</span><span style="color:#f92672">&gt;</span>
  	<span style="color:#f92672">&lt;filter-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/filter-name&gt;</span>
  	<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.shtml<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  <span style="color:#f92672">&lt;/filter-mapping&gt;</span>
  <span style="color:#f92672">&lt;filter-mapping</span><span style="color:#f92672">&gt;</span>
  	<span style="color:#f92672">&lt;filter-name</span><span style="color:#f92672">&gt;</span>encoding<span style="color:#f92672">&lt;/filter-name&gt;</span>
  	<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.do<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  <span style="color:#f92672">&lt;/filter-mapping&gt;</span>
</code></pre></div><h6 id="2springmvc">2.配置Springmvc前端控制器</h6>
<pre><code> 注：前端控制器是获得请求后才加载，为了让它在tomcat启动时加载
 设置&lt;load-on-startup&gt;1&lt;/load-on-startup&gt; 其中数字表示加载顺序
</code></pre>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	 <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc前端控制器    前台 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>front<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#f92672">&lt;servlet-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.servlet.DispatcherServlet<span style="color:#f92672">&lt;/servlet-class&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定配置文件所在位置 
</span><span style="color:#75715e">  			不配置init</span><span style="color:#75715e">-</span><span style="color:#75715e">param 默认到/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/找配置文件
</span><span style="color:#75715e">  			/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/servlet的名称</span><span style="color:#75715e">-</span><span style="color:#75715e">servlet.xml
</span><span style="color:#75715e">  		</span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		 	<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>contextConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>
  		 	<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>classpath:springmvc-front.xml<span style="color:#f92672">&lt;/param-value&gt;</span>
  		<span style="color:#f92672">&lt;/init-param&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 随着Tomcat启动而加载 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;load-on-startup</span><span style="color:#f92672">&gt;</span>1<span style="color:#f92672">&lt;/load-on-startup&gt;</span>
  <span style="color:#f92672">&lt;/servlet&gt;</span>
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc前端控制器    后台 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>back<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#f92672">&lt;servlet-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.servlet.DispatcherServlet<span style="color:#f92672">&lt;/servlet-class&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定配置文件所在位置 
</span><span style="color:#75715e">  			不配置init</span><span style="color:#75715e">-</span><span style="color:#75715e">param 默认到/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/找配置文件
</span><span style="color:#75715e">  			/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/servlet的名称</span><span style="color:#75715e">-</span><span style="color:#75715e">servlet.xml
</span><span style="color:#75715e">  		</span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		 	<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>contextConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>
  		 	<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>classpath:springmvc-back.xml<span style="color:#f92672">&lt;/param-value&gt;</span>
  		<span style="color:#f92672">&lt;/init-param&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 随着Tomcat启动而加载 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;load-on-startup</span><span style="color:#f92672">&gt;</span>2<span style="color:#f92672">&lt;/load-on-startup&gt;</span>
  <span style="color:#f92672">&lt;/servlet&gt;</span>

	     <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc前端控制器    后台 </span><span style="color:#75715e">--&gt;</span>
  <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>back<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#f92672">&lt;servlet-class</span><span style="color:#f92672">&gt;</span>org.springframework.web.servlet.DispatcherServlet<span style="color:#f92672">&lt;/servlet-class&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定配置文件所在位置 
</span><span style="color:#75715e">  			不配置init</span><span style="color:#75715e">-</span><span style="color:#75715e">param 默认到/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/找配置文件
</span><span style="color:#75715e">  			/WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/servlet的名称</span><span style="color:#75715e">-</span><span style="color:#75715e">servlet.xml
</span><span style="color:#75715e">  		</span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
  		 	<span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>contextConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>
  		 	<span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>classpath:springmvc-back.xml<span style="color:#f92672">&lt;/param-value&gt;</span>
  		<span style="color:#f92672">&lt;/init-param&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 随着Tomcat启动而加载 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;load-on-startup</span><span style="color:#f92672">&gt;</span>2<span style="color:#f92672">&lt;/load-on-startup&gt;</span>
  <span style="color:#f92672">&lt;/servlet&gt;</span>
</code></pre></div><div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">   <span style="color:#f92672">&lt;servlet-mapping</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>front<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> *.action 
</span><span style="color:#75715e">  		   请求路径必须是.action
</span><span style="color:#75715e">  		 第一种:/*   拦截所有请求   弊端  /WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/jsp/items.jsp  报错 404找不到此请求路径 
</span><span style="color:#75715e">  		 第二种:/    拦截所有请求   弊端  .js  .css .jpg  ....   报错:样式找不到  js找不一到
</span><span style="color:#75715e">  		                       ( 配置静态资源不要进行拦截)
</span><span style="color:#75715e">  		
</span><span style="color:#75715e">  		 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.shtml<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  	<span style="color:#f92672">&lt;/servlet-mapping&gt;</span>
  	
    <span style="color:#f92672">&lt;servlet-mapping</span><span style="color:#f92672">&gt;</span>
  		<span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>back<span style="color:#f92672">&lt;/servlet-name&gt;</span>
  		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> *.action 
</span><span style="color:#75715e">  		   请求路径必须是.action
</span><span style="color:#75715e">  		 第一种:/*   拦截所有请求   弊端  /WEB</span><span style="color:#75715e">-</span><span style="color:#75715e">INF/jsp/items.jsp  报错 404找不到此请求路径 
</span><span style="color:#75715e">  		 第二种:/    拦截所有请求   弊端  .js  .css .jpg  ....   报错:样式找不到  js找不一到
</span><span style="color:#75715e">  		                       ( 配置静态资源不要进行拦截)
</span><span style="color:#75715e">  		
</span><span style="color:#75715e">  		 </span><span style="color:#75715e">--&gt;</span>
  		<span style="color:#f92672">&lt;url-pattern</span><span style="color:#f92672">&gt;</span>*.do<span style="color:#f92672">&lt;/url-pattern&gt;</span>
  	<span style="color:#f92672">&lt;/servlet-mapping&gt;</span>
</code></pre></div><h6 id="springmvcbackxml">springmvc-back.xml(后台)</h6>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#f92672">&lt;beans</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans&#34;</span>
	<span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span> <span style="color:#a6e22e">xmlns:mvc=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/mvc&#34;</span>
	<span style="color:#a6e22e">xmlns:context=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/context&#34;</span>
	<span style="color:#a6e22e">xmlns:aop=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/aop&#34;</span> <span style="color:#a6e22e">xmlns:tx=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/tx&#34;</span>
	<span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd &#34;</span><span style="color:#f92672">&gt;</span>


	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置 处理器  本身不用配置这里   配置扫描处理器</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.itcast&#34;</span> <span style="color:#a6e22e">use-default-filters=</span><span style="color:#e6db74">&#34;false&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;context:include-filter</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;annotation&#34;</span> <span style="color:#a6e22e">expression=</span><span style="color:#e6db74">&#34;org.springframework.stereotype.Controller&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/context:component-scan&gt;</span>
	
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 视图解释器     jspViewResolver 默认支持 jstl </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.view.InternalResourceViewResolver&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置前缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;prefix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;/WEB-INF/back_page/&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置后缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;suffix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;.jsp&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发第二种配置文式  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;mvc:annotation-driven</span> <span style="color:#a6e22e">conversion-service=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#f92672">/&gt;</span>

	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数格式  字符串类型  yyyy</span><span style="color:#75715e">-</span><span style="color:#75715e">MM</span><span style="color:#75715e">-</span><span style="color:#75715e">dd HH</span><span style="color:#75715e">-</span><span style="color:#75715e">mm</span><span style="color:#75715e">-</span><span style="color:#75715e">ss  格式化  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.format.support.FormattingConversionServiceFactoryBean&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;converters&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;list</span><span style="color:#f92672">&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 日期转换 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomDateConverter&#34;</span><span style="color:#f92672">/&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数 传递 前后去掉空格 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomTrimConverter&#34;</span><span style="color:#f92672">/&gt;</span>
			<span style="color:#f92672">&lt;/list&gt;</span>
		<span style="color:#f92672">&lt;/property&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc支持上传图片 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;multipartResolver&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.multipart.commons.CommonsMultipartResolver&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定上传大小  上传的图片不能超过1M    默认是 B </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;maxUploadSize&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;1048576&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
		
<span style="color:#f92672">&lt;/beans&gt;</span>
</code></pre></div><h6 id="springmvcfrontxml">springmvc-front.xml（前台）</h6>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#f92672">&lt;beans</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans&#34;</span>
	<span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span> <span style="color:#a6e22e">xmlns:mvc=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/mvc&#34;</span>
	<span style="color:#a6e22e">xmlns:context=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/context&#34;</span>
	<span style="color:#a6e22e">xmlns:aop=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/aop&#34;</span> <span style="color:#a6e22e">xmlns:tx=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/tx&#34;</span>
	<span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;http://www.springframework.org/schema/beans 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx 
</span><span style="color:#e6db74">		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd &#34;</span><span style="color:#f92672">&gt;</span>


	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置 处理器  本身不用配置这里   配置扫描处理器</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.itcast&#34;</span> <span style="color:#a6e22e">use-default-filters=</span><span style="color:#e6db74">&#34;false&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;context:include-filter</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;annotation&#34;</span> <span style="color:#a6e22e">expression=</span><span style="color:#e6db74">&#34;org.springframework.stereotype.Controller&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/context:component-scan&gt;</span>
	注：
	include 白明单，表示必须扫描，不代表扫描器停止。设置use-default-filters=&#34;false&#34;表示扫描白明单后必须停止。
	表示只扫描Controller层
 exclude-filter 	黑明单 屏蔽掉，指定不扫描指定注解。
	
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 视图解释器     jspViewResolver 默认支持 jstl </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.servlet.view.InternalResourceViewResolver&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置前缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;prefix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;/WEB-INF/front_page/&#34;</span><span style="color:#f92672">/&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置后缀 </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;suffix&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;.jsp&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发第二种配置文式  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;mvc:annotation-driven</span> <span style="color:#a6e22e">conversion-service=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#f92672">/&gt;</span>
	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数格式  字符串类型  yyyy</span><span style="color:#75715e">-</span><span style="color:#75715e">MM</span><span style="color:#75715e">-</span><span style="color:#75715e">dd HH</span><span style="color:#75715e">-</span><span style="color:#75715e">mm</span><span style="color:#75715e">-</span><span style="color:#75715e">ss  格式化  </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;conversionService&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.format.support.FormattingConversionServiceFactoryBean&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;converters&#34;</span><span style="color:#f92672">&gt;</span>
			<span style="color:#f92672">&lt;list</span><span style="color:#f92672">&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 日期转换 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomDateConverter&#34;</span><span style="color:#f92672">/&gt;</span>
				<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 参数 传递 前后去掉空格 </span><span style="color:#75715e">--&gt;</span>
				<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;cn.itcast.common.converter.CustomTrimConverter&#34;</span><span style="color:#f92672">/&gt;</span>
			<span style="color:#f92672">&lt;/list&gt;</span>
		<span style="color:#f92672">&lt;/property&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>	
	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 配置Springmvc支持上传图片 </span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt;bean</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;multipartResolver&#34;</span> <span style="color:#a6e22e">class=</span><span style="color:#e6db74">&#34;org.springframework.web.multipart.commons.CommonsMultipartResolver&#34;</span><span style="color:#f92672">&gt;</span>
		<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 指定上传大小  上传的图片不能超过1M    默认是 B </span><span style="color:#75715e">--&gt;</span>
		<span style="color:#f92672">&lt;property</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;maxUploadSize&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;1048576&#34;</span><span style="color:#f92672">/&gt;</span>
	<span style="color:#f92672">&lt;/bean&gt;</span>
		
<span style="color:#f92672">&lt;/beans&gt;</span>
</code></pre></div><h6 id="heading7"><code>注：</code></h6>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">	<span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 注解开发  扫描包</span><span style="color:#75715e">--&gt;</span>
	<span style="color:#f92672">&lt; context:component-scan</span> <span style="color:#a6e22e">base-package=</span><span style="color:#e6db74">&#34;cn.itcast&#34;</span><span style="color:#f92672">/&gt;</span>
	```
	这样配置会使Springmvc 与 spring 扫描冲突
	Springmvc扫描的会覆盖Spring的 

**Controller**  
	由Springmvc管理并扫描  
**Service**  
	由Spring 管理并扫描  
**Dao**  
	由Mybatis自己扫描 （由于没有注解所以Spring管不了）
	
###### 日志配置
1.  在web.xml中
```xml
<span style="color:#75715e">&lt;!--</span><span style="color:#75715e">log4j配置文件加载</span><span style="color:#75715e">--&gt;</span>  
   <span style="color:#f92672">&lt;context-param</span><span style="color:#f92672">&gt;</span>      
       <span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>log4jConfigLocation<span style="color:#f92672">&lt;/param-name&gt;</span>      
       <span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>/WEB-INF/log4j.properties<span style="color:#f92672">&lt;/param-value&gt;</span>      
   <span style="color:#f92672">&lt;/context-param&gt;</span>  
   <span style="color:#75715e">&lt;!--</span><span style="color:#75715e">启动一个watchdog线程每1800秒扫描一下log4j配置文件的变化</span><span style="color:#75715e">--&gt;</span>  
   <span style="color:#f92672">&lt;context-param</span><span style="color:#f92672">&gt;</span>      
       <span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>log4jRefreshInterval<span style="color:#f92672">&lt;/param-name&gt;</span>      
       <span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>1800000<span style="color:#f92672">&lt;/param-value&gt;</span>      
   <span style="color:#960050;background-color:#1e0010">&lt;</span>/context-param
</code></pre></div><ol start="2">
<li>把log4j.properties配置文件放在上面配置的指定的目录下
log4j.properties配置文件：</li>
</ol>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">
    ######################################  
    #         log4j配置相关说明  
    ######################################  
      
    #%p 输出优先级，即DEBUG，INFO，WARN，ERROR，FATAL   
    #%r 输出自应用启动到输出该log信息耗费的毫秒数   
    #%c 输出所属的类目，通常就是所在类的全名   
    #%t 输出产生该日志事件的线程名  
    #%m 输出代码中指定的信息   
    #%n 输出一个回车换行符，Windows平台为“\r\n”，Unix平台为“\n”   
    #%d 输出日志时间点的日期或时间，默认格式为ISO8601，也可以在其后指定格式，比如：%d{yyyy MM dd HH:mm:ss,SSS}，输出类似： 2002年10月18日 22：10：28，921   
    #%l 输出日志事件的发生位置，包括类目名、发生的线程，以及在代码中的行数。举例：Testlog4.main(TestLog4.java:10)   
      
    #log4j提供4种布局:   
    #org.apache.log4j.HTMLLayout（以HTML表格形式布局）  
    #org.apache.log4j.PatternLayout（可以灵活地指定布局模式），  
    #org.apache.log4j.SimpleLayout（包含日志信息的级别和信息字符串），  
    #org.apache.log4j.TTCCLayout（包含日志产生的时间、线程、类别等等信息  
      
    #log4j中有五级logger 输出级别:  
    #FATAL 0   
    #ERROR 3   
    #WARN 4   
    #INFO 6   
    #DEBUG 7  
      
    ######################################  
    #          log4j相关配置  
    ######################################  
      
    #日志输出级别  
    log4j.rootLogger=INFO,stdout,other  
      
    #设置stdout的日志输出控制台  
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender  
    #输出日志到控制台的方式，默认为System.out  
    log4j.appender.stdout.Target = System.out  
    #设置使用灵活布局  
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  
    #灵活定义输出格式  
    log4j.appender.stdout.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %m %n    
      
    #设置other的日志输出控制台  
    log4j.appender.other=org.apache.log4j.RollingFileAppender  
    #设置other的输出日志  
    log4j.appender.other.File=${webapp.root}/WEB-INF/logs/log.log  
    #设置other的日志最大限制  
    log4j.appender.other.MaxFileSize=1024KB  
    #最多只保存20个备份文件  
    log4j.appender.other.MaxBackupIndex=1000  
    #输出INFO级别以上的日志  
    og4j.appender.other.Threshold=INFO   
    #设置使用灵活布局  
    log4j.appender.other.layout=org.apache.log4j.PatternLayout  
    #灵活定义输出格式  
    log4j.appender.other.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n    

		######################################  
    #       Mybatis相关配置   
    ######################################  
		    log4j.rootLogger=DEBUG, Console
				#Console
				log4j.appender.Console=org.apache.log4j.ConsoleAppender
				log4j.appender.Console.layout=org.apache.log4j.PatternLayout
				log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
				log4j.logger.java.sql.ResultSet=INFO
				log4j.logger.org.apache=INFO
				log4j.logger.java.sql.Connection=DEBUG
				log4j.logger.java.sql.Statement=DEBUG
				log4j.logger.java
		
		
    ######################################  
    #       hibernate相关配置  
    ######################################  
      
    #输出hibernate调试过程中的错误日志  
    log4j.logger.org.hibernate=other  
    #输出HQL查询调试日志  
    log4j.logger.org.hibernate.hql.ast.AST=other  
    #输出SQL语句调试日志  
    log4j.logger.org.hibernate.SQL=other  
    #输出 JDBC参数查询的日志  
    log4j.logger.org.hibernate.type=other  
    #输出缓存日志   
    log4j.logger.org.hibernate.cache=other  
    #输出事务日志  
    log4j.logger.org.hibernate.transaction=other  
    #输出获取JDBC资源日志  
    log4j.logger.org.hibernate.jdbc=other
</code></pre></div><hr>
<p>问题1.web.xml  web-app命名空间最新配置获取
用tomcat\webapps\examples\WEB-INF\web.xml
中web-app 替换项目中web-app</p>
<p>问题2.
META-INF &ndash;&gt;spring.schemas</p>
<p>问题3.
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalArgumentException</p>
<hr>
<h3 id="heading8">上传图片</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">		<span style="color:#75715e">//使用Jersey框架
</span><span style="color:#75715e"></span>		Client client<span style="color:#f92672">=</span><span style="color:#66d9ef">new</span> Client<span style="color:#f92672">(</span><span style="color:#f92672">)</span><span style="color:#f92672">;</span>
		String url<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://localhost:8080/Img-web/upload/ppp.jsp&#34;</span><span style="color:#f92672">;</span>
		client<span style="color:#f92672">.</span><span style="color:#a6e22e">resource</span><span style="color:#f92672">(</span>url<span style="color:#f92672">)</span><span style="color:#f92672">;</span>
</code></pre></div><p>tomcat 默认只能读取不能写入
tomcat 可读写配置：
conf&ndash;&gt;web.xml 添加</p>
<pre><code>				 &lt;init-param&gt;
            &lt;param-name&gt;readonly&lt;/param-name&gt;
            &lt;param-value&gt;false&lt;/param-value&gt;
        &lt;/init-param&gt;
</code></pre><p>添加位置和结果</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">    <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span>
        <span style="color:#f92672">&lt;servlet-name</span><span style="color:#f92672">&gt;</span>default<span style="color:#f92672">&lt;/servlet-name&gt;</span>
        <span style="color:#f92672">&lt;servlet-class</span><span style="color:#f92672">&gt;</span>org.apache.catalina.servlets.DefaultServlet<span style="color:#f92672">&lt;/servlet-class&gt;</span>
        <span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
            <span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>debug<span style="color:#f92672">&lt;/param-name&gt;</span>
            <span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>0<span style="color:#f92672">&lt;/param-value&gt;</span>
        <span style="color:#f92672">&lt;/init-param&gt;</span>
				 <span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
            <span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>readonly<span style="color:#f92672">&lt;/param-name&gt;</span>
            <span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>false<span style="color:#f92672">&lt;/param-value&gt;</span>
        <span style="color:#f92672">&lt;/init-param&gt;</span>
        <span style="color:#f92672">&lt;init-param</span><span style="color:#f92672">&gt;</span>
            <span style="color:#f92672">&lt;param-name</span><span style="color:#f92672">&gt;</span>listings<span style="color:#f92672">&lt;/param-name&gt;</span>
            <span style="color:#f92672">&lt;param-value</span><span style="color:#f92672">&gt;</span>false<span style="color:#f92672">&lt;/param-value&gt;</span>
        <span style="color:#f92672">&lt;/init-param&gt;</span>
        <span style="color:#f92672">&lt;load-on-startup</span><span style="color:#f92672">&gt;</span>1<span style="color:#f92672">&lt;/load-on-startup&gt;</span>
    <span style="color:#f92672">&lt;/servlet&gt;</span>
</code></pre></div><p>异步返回用 HttpServletResponse
用JSON 返回需要设置返回类型</p>
<h3 id="powerdesiner-">PowerDesiner 表结构设计</h3>

</div>


  
</article>
      <footer id="main-footer" class="container main_footer">
  

  <div class="container nav foot no-print">
  
<a href="https://lvzongcheng.gitee.io/license">license</a>


  <a class="toplink" href="#">back to top</a>

</div>

  <div class="container credits">
  
<div class="container footline">
  
  code with <!-- raw HTML omitted --><!-- raw HTML omitted -->


</div>


  
<div class="container copyright">
  
  (c) 2015 yourname.


</div>


</div>

</footer>

    </main>
    
<script type="text/javascript">
  (function() {
    
    
    if (window.location.hostname == "localhost")
      return;
    var dsq = document.createElement('script'); dsq.async = true; dsq.type = 'text/javascript';
    dsq.src = '//your_disqus_shortname.disqus.com/count.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
</script>



<script src="/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>



    
  </body>
</html>

